package loop;

public class for2 {
    public static void main(String[] args) {
        for (int i = 1; i <= 100; i++) {
            System.out.println(i);
        }

        System.out.println("----------------------------");


        int sum1 = 0;

        for (int i = 1; i<= 5; i++) {
            sum1 = sum1 +i;
        }

        System.out.println("1-5的数据和：" + sum1);


        System.out.println("------------------------------");


        int sum2 = 0;

        for (int i = 1; i<= 100; i++) {
            sum2 = sum2 +i;
        }

        System.out.println("1-100的数据和：" + sum2);


        System.out.println("-------------------------");



        int sum3 = 0;
        for (int i = 0; i <= 100; i+=2) {
            sum3 += i;
        }
        System.out.println("1-100的奇数和：" + sum3);

        System.out.println("-----------------------------");

        int sum4 = 0;

        for (int i = 1; i <= 100; i++) {
            if (i % 2 ==1){
                sum4 += i;
            }

        }
        System.out.println("1-100的奇数和" + sum4);
    }
}
